package com.woniu.core.controller;

import com.woniu.aop.OperationLogAnnotation;
import com.woniu.core.entity.CoreCompensation;
import com.woniu.core.service.CoreCompensationService;
import com.woniu.util.utils.HttpResult;
import com.woniu.util.utils.RequestParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/compensation")
@Slf4j
public class CoreCompensationController {
    @Autowired
    private CoreCompensationService compensationService;

    @PostMapping("/allCompensation")
//    @PreAuthorize("hasAuthority('core:finance')")
    @OperationLogAnnotation(operModul = "核心企业-财务部门", operType = "查询", operDesc = "查询所有代偿记录")
    @ApiOperation(value = "查询所有代偿记录", notes = "查询所有代偿记录")
    public HttpResult<?> checkCompensation(@RequestBody RequestParam<String> requestParam) {
        return compensationService.checkCompensation(requestParam);
    }

    @GetMapping("/findCompensationById")
//    @PreAuthorize("hasAuthority('core:finance')")
    @OperationLogAnnotation(operModul = "核心企业-财务部门", operType = "查询", operDesc = "查询所有平台推送需要代偿的记录")
    @ApiOperation(value = "查询所有平台推送需要代偿的记录", notes = "查询所有代偿记录")
    public HttpResult<?> findCompensationById(String coreUserAccount) {
        return compensationService.findCompensationById(coreUserAccount);
    }

    @GetMapping("/doCompensation")
//    @PreAuthorize("hasAuthority('core:finance')")
    @OperationLogAnnotation(operModul = "核心企业-财务部门", operType = "新增", operDesc = "代偿后添加代偿记录")
    @ApiOperation(value = "代偿后添加代偿记", notes = "查询所有代偿记录")
    public HttpResult<?> doCompensation(Integer tenderId) {
        return compensationService.doCompensation(tenderId);
    }

}
